package org.zls.client.login;

import org.zls.client.Util;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class Login extends Composite {

	private VerticalPanel panel;
	private HorizontalPanel emailPanel;
	private HorizontalPanel passwordPanel;
	
	private Button button;
	
	
	private TextBox email;
	private PasswordTextBox password;
	
	public Login() {
		panel = new VerticalPanel();
		panel.setSpacing(8);
		
		email = new TextBox();
		password = new PasswordTextBox();
		
		emailPanel = new HorizontalPanel();
		emailPanel.setVerticalAlignment(VerticalPanel.ALIGN_BOTTOM);
		emailPanel.setSpacing(4);
		emailPanel.add(new HTML("FAS E-mail:"));
		emailPanel.add(email);
		
		passwordPanel = new HorizontalPanel();
		passwordPanel.setVerticalAlignment(VerticalPanel.ALIGN_BOTTOM);
		passwordPanel.setSpacing(4);
		passwordPanel.add(new HTML("Password:"));
		passwordPanel.add(password);
		
		button = new Button("Login");
		button.setWidth("50px");
		button.addClickListener(new ClickListener() {

			public void onClick(Widget sender) {
				Util.validateLogin(email.getText(), password.getText());
			}
			
		});
		
		panel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
		
		panel.add(emailPanel);
		panel.add(passwordPanel);
		panel.add(button);
		
		initWidget(panel);
	}
}
